<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CodeSmackdown.Web.Models.SnippetModel>" %>
<table style="width: 100%">
    <tr>
        <td colspan="2" align="center">
            <h2><%= Html.Encode(ViewData.Model.Snippet.Title) %></h2>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center">
            Total of <b><%= ViewData.Model.TotalVotes %></b> Vote<%= (ViewData.Model.TotalVotes == 1) ? "" : "s" %>            
        </td>
    </tr>
    <% if (ViewData.Model.CurrentUserVoted)
       { %>
    <tr>
        <% if (ViewData.Model.VoteCountSnippet1 > ViewData.Model.VoteCountSnippet2)
           { %>
        <td class="vote winner"><%= ViewData.Model.VoteCountSnippet1%> Votes</td>
        <td class="vote loser" align="right"><%= ViewData.Model.VoteCountSnippet2%> Votes</td>
        <% }
           else if (ViewData.Model.VoteCountSnippet1 < ViewData.Model.VoteCountSnippet2)
           { %>
        <td class="vote loser"><%= ViewData.Model.VoteCountSnippet1%> Votes</td>
        <td class="vote winner" align="right"><%= ViewData.Model.VoteCountSnippet2%> Votes</td>
        <% }
           else
           { %>
        <td class="vote even"><%= ViewData.Model.VoteCountSnippet1%> Votes</td>
        <td class="vote even" align="right"><%= ViewData.Model.VoteCountSnippet2%> Votes</td>
        <% } %>
    </tr>
    <% } %>
    <tr>
        <td class="code" width="50%">
            <div>
                <pre><code><%= Html.Encode(ViewData.Model.Snippet.Snippet1) %></code></pre>
            </div>
        </td>
        <td class="code" width="50%">
            <div>
                <pre><code><%= Html.Encode(ViewData.Model.Snippet.Snippet2)%></code></pre>
            </div>
        </td>
    </tr>
    <tr>
        <td>
            <%= Html.ActionLink("Permalink", "ViewSnippet", "Home", new { snippetID = ViewData.Model.Snippet.SnippetID }, new { })%>
        </td>
    </tr>
    <tr>
        <% if (ViewData.Model.CurrentUserVoted)
           {
               if (ViewData.Model.CurrentUserVotedSnippet1.HasValue)
               { %>
        <td>
            <% if (ViewData.Model.CurrentUserVotedSnippet1.Value)
               { %>
            ^^ You voted for this snippet
            <% } %>
        </td>
        <td align="right">
            <% if (!ViewData.Model.CurrentUserVotedSnippet1.Value)
               { %>
            You voted for this snippet ^^^
            <% } %>
        </td>
        <% }
               else
               { %>
        <td align="center" colspan="2">
            ^^^ You voted for neither of these ^^^
        </td>
        <% }
           }
           else if (Request.IsAuthenticated)
           { %>
        <td colspan='2'>
            <% using (Html.BeginForm("VoteSnippet1", "Home"))
               { %>
            <span style="float: left; padding-left: 120px; padding-top: 10px">
                <input id="voteHot" name="vote" type="submit" value="^^ That is hot! " class="hotbutton" /></span>
            <% } %>
            <% using (Html.BeginForm("VoteSnippet2", "Home"))
               { %>
            <span style="float: right; padding-right: 120px; padding-top: 10px">
                <input id="voteNot" name="vote" type="submit" value="No, This is hot! ^^" class="hotbutton" /></span>
            <% } %>
            <% using (Html.BeginForm("VoteNeither", "Home"))
               { %>
            <center style="padding-top: 10px">
                <input id="voteNone" name="vote" type="submit" value="both FAIL" class="notbutton" /></center>
            <% } %>
        </td>
        <% }
           else
           { %>
        <td align="center" colspan="2">
            Please
            <%= Html.ActionLink("login", "LogOn", "Account", new {}, new {}) %>      
            to vote. (Or <%= Html.ActionLink("register", "Register", "Account") %>)
        </td>
        <% } %>
    </tr>
</table>

           <div id="submitcontainer">
                <ul class="navmenu">     
                         
                    <li><%= Html.ActionLink("<< Previous", "Previous", "Snippet")%></li>
                    <li><%= Html.ActionLink("Next >>", "Next", "Snippet")%></li>
                </ul>
            </div>            
